using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.WizardFramework;
using System.ComponentModel.Design;
using System.Windows.Forms;
using EnvDTE;
using Microsoft.Practices.RecipeFramework.Services;

namespace VSShellAssist.Recipes.Common.CustomPages
{
	/// <summary>
	/// WizardPage base class.
	/// </summary>
	public class WizardPageBase : CustomWizardPage
	{
		private DTE visualStudio;
		private IDictionaryService dictionaryService;

		#region Protected Properties
		/// <summary>
		/// Gets the visual studio.
		/// </summary>
		/// <value>The visual studio.</value>
		protected DTE VisualStudio
		{
			get
			{
				if(this.visualStudio == null)
				{
					this.visualStudio = this.GetService(typeof(DTE)) as DTE;
				}

				return this.visualStudio;
			}
		}

		/// <summary>
		/// Gets the dictionary service.
		/// </summary>
		/// <value>The dictionary service.</value>
		protected IDictionaryService DictionaryService
		{
			get 
			{
				if(this.dictionaryService == null)
				{
					this.dictionaryService = GetService(typeof(IDictionaryService)) as IDictionaryService;
				}

				return this.dictionaryService;
			}
		}
		#endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="WizardPageBase"/> class.
		/// </summary>
		public WizardPageBase()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="WizardPageBase"/> class.
		/// </summary>
		/// <param name="wizard">The <see cref="T:Microsoft.Practices.WizardFramework.WizardForm"/>that will host the new page.</param>
		public WizardPageBase(WizardForm wizard)
			: base(wizard)
		{
		}

		/// <summary>
		/// Raises the <see cref="E:System.Windows.Forms.UserControl.Load"></see> event.
		/// </summary>
		/// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
		protected override void OnLoad(EventArgs e)
		{
			if(!this.DesignMode)
			{
                this.Logo = VSShellAssist.Properties.Resources.VSShellAssistLogo;
                this.Wizard.Title = VSShellAssist.Properties.Resources.VSShellAssist;
			}

			base.OnLoad(e);
		}

		/// <summary>
		/// Initializes the controls.
		/// </summary>
		protected virtual void InitializeControls()
		{
		}

		/// <summary>
		/// Gets the package base path.
		/// </summary>
		/// <returns></returns>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
		protected virtual String GetPackageBasePath()
		{
			IConfigurationService configService = this.GetService(typeof(IConfigurationService)) as IConfigurationService;
			return configService.BasePath;
		} 
	}
}